<?php
  include_once(dirname(__FILE__)."/../../database/database.class.php");
  include_once(dirname(__FILE__)."/../../classes/expansion.class.php");
  include_once(dirname(__FILE__)."/../../classes/collection.class.php");
  include_once(dirname(__FILE__)."/../../classes/deck.class.php");

  function getSelectOptions($collections)
  {
    $options = "";
    
    foreach($collections as $collection)
    {
      $options .= '<option value="'.$collection->getID().'" style="background:white;">'.$collection->getName().'</option>'."\n";
    }
    
    return $options;
  }
?>

<form action="./search.php" method="get" style="max-width:500px;">
  <fieldset>
    <legend>Card header</legend>
    <div style="float:left;">
      <h4>Name:</h4>
      <input type="text" name="cardname">
    </div>
    <div style="float:right;">
      <h4>Mana cost:</h4>
      <input type="text" name="manacostlow" size="3" maxlength="3" value="0"> - <input type="text" name="manacosthigh" size="3" maxlength="3" value="100">
    </div>
  </fieldset>

  <fieldset style="clear:both;">
    <legend>Card color</legend>
    <h4 style="clear:both;">Included colors</h4>
    <input type="checkbox" name="colors[]" class="color_checkbox" id="CBOX_INC_RED" value="Red">
    <input type="checkbox" name="colors[]" class="color_checkbox" id="CBOX_INC_GREEN" value="Green">
    <input type="checkbox" name="colors[]" class="color_checkbox" id="CBOX_INC_BLUE" value="Blue">
    <input type="checkbox" name="colors[]" class="color_checkbox" id="CBOX_INC_WHITE" value="White">
    <input type="checkbox" name="colors[]" class="color_checkbox" id="CBOX_INC_BLACK" value="Black">
    <input type="checkbox" name="colors[]" class="color_checkbox" id="CBOX_INC_COLORLESS" value="Colorless">
    <select name="color_operator"><br>
      <option value="OR">OR</option>
      <option value="AND">AND</option>
      <option value="XOR">XOR</option>
    </select><br>
    <h4>Excluded colors</h4>
    <input type="checkbox" name="excluded_colors[]" class="color_checkbox" id="CBOX_EXC_RED" value="Red">
    <input type="checkbox" name="excluded_colors[]" class="color_checkbox" id="CBOX_EXC_GREEN" value="Green">
    <input type="checkbox" name="excluded_colors[]" class="color_checkbox" id="CBOX_EXC_BLUE" value="Blue">
    <input type="checkbox" name="excluded_colors[]" class="color_checkbox" id="CBOX_EXC_WHITE" value="White">
    <input type="checkbox" name="excluded_colors[]" class="color_checkbox" id="CBOX_EXC_BLACK" value="Black">
    <input type="checkbox" name="excluded_colors[]" class="color_checkbox" id="CBOX_EXC_COLORLESS" value="Colorless">
  </fieldset>
  
  <fieldset>
    <legend>Available in</legend>
    
    <div style="float:left;">
      <h4>Type:</h4>
      <input type="text" name="type">
    </div>
    <div style="float:right;">
      <div>
      <h4>Rarity</h4>
        <div style="float:left; margin-right:5px;">
          <input type="checkbox" name="rarity[]" class="rarity_checkbox" id="CBOX_MYTHIC" value="mythic rare"><div style="background:#D98719; border:1px solid black; width:18px; height:18px; text-align:center;">M</div>
        </div>
        <div style="float:left; margin-right:5px;"">
          <input type="checkbox" name="rarity[]" class="rarity_checkbox" id="CBOX_RARE" value="rare"><div style="background:#DBDB70; border:1px solid black; width:18px; height:18px; text-align:center;">R</div>
        </div>
        <div style="float:left; margin-right:5px;"">
          <input type="checkbox" name="rarity[]" class="rarity_checkbox" id="CBOX_UNCOMMON" value="uncommon"><div style="background:#92a6a4; border:1px solid black; width:18px; height:18px; text-align:center;">U</div>
        </div>
        <div style="float:left; margin-right:5px;"">
          <input type="checkbox" name="rarity[]" class="rarity_checkbox" id="CBOX_COMMON" value="common"><div style="background:#000000; color:white; border:1px solid black; width:18px; height:18px; text-align:center;">C</div>
        </div>
        <div style="float:left; margin-right:5px;"">
          <input type="checkbox" name="rarity[]" class="rarity_checkbox" id="CBOX_BASIC_LAND" value="basic land"><div style="background:#000000; color:white; border:1px solid black; width:18px; height:18px; text-align:center;">BL</div>
        </div>
      </div>
      <div style="clear:both;">
<?php
    include "expansion.select.inc.php";
?>
      </div>
    </div>
  </fieldset>

  <fieldset>
    <legend>Card text</legend>
    <h4>Card text:</h4>
    <input type="text" name="cardtext"><br>
    <h4>Flavor text:</h4>
    <input type="text" name="flavortext"><br>
  </fieldset>
  
  <fieldset>
    <legend>Card power</legend>
    <h4>Power / Toughness</h4>
    <input type="text" name="power"> / <input type="text" name="toughness"><br>
    
    <h4>Loyalty</h4>
    <input type="text" name="loyalty"><br>
  </fieldset>
  
  <fieldset>
    <legend>Archived in</legend>
<?php
    include "collection.select.inc.php";
?>
  </fieldset>

  <input type="submit" value="Search">  
</form>
